<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateUserBrowseTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('user_browse', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id',false)->index()->default(0)->comment('用户id');
            $table->string('behavior_type',15)->default('behavior')->index()->comment('行为类型 access=访问 browse=浏览 behavior=行为');
            $table->string('from_platform',90)->nullable()->comment('来源 h5 小程序 app');
            $table->string('device_id',90)->nullable()->comment('设备id');
            $table->string('device_type',12)->default('Android')->comment('设备类型');
            $table->string('device_model',20)->nullable()->comment('设备型号');
            $table->string('data_module',15)->nullable()->comment('行为数据模块');
            $table->string('data_model',15)->nullable()->comment('行为数据类型');
            $table->unsignedBigInteger('data_id',false)->nullable()->index()->comment('行为数据id');
            $table->text('extra_info')->nullable()->comment('行为扩展数据');
            $table->timestamps();
            $table->engine="InnoDb";
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('user_browse');
    }
}
